package com.twu.biblioteca.service;

import com.twu.biblioteca.model.movieModel;

import java.io.InputStream;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: st
 * Date: 14-4-22
 * Time: 下午9:56
 * To change this template use File | Settings | File Templates.
 */
public class checkOutMovie {
    public String checkMovieInfo(InputStream in){
        System.out.println("\n Please enter movie name.");

        Scanner sc = new Scanner(in);
        String movieName = sc.nextLine();
        return movieName;
    }
    public movieModel[] checkOut(movieModel[] movieList,String movieNameEnter){
        int len = 0;
        boolean exit=false;
        while (len<movieList.length&&movieList[len]!=null&&!movieList[len].getCheckStatus()) {
            if (movieList[len].getMovieName().equals(movieNameEnter))
            {
                movieList[len].setCheckStatus(true);
                System.out.println("Thank you! Enjoy the movie");
                exit=true;
                break;
            }
            len++;
        }
        if (!exit)
            System.out.println("That movie is not available.");

        return movieList;
    }
}
